import store from '../store'
import router from '@/router'
import {GetUserPermissionsByKeys} from '@/api/user'

// 获取用户权限路由
export const getRouter=function(response){
    GetUserPermissionsByKeys({sessionKey:response.SessionKey}).then((res)=>{
        return  store.dispatch('permission/generateRoutes',res.Result)
    }).then((res)=>{
        router.addRoutes(res)
        router.addRoutes(Array.of({
            path: '*',
            redirect: '/login',
            component: () => import('@/views/error-page/404')
        }))
        router.push({ path: '/dashboard' })
    }).catch((error)=>{
        store.dispatch('user/logout')
    })
}

  